home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cmln0186.arc / DEVICE1.LTG < prev    next >
Text File  |  1986-12-20  |  7KB  |  253 lines

  1.                  
  2.  
  3.                             Listing 1
  4.  
  5. ;****************************************************************
  6. ;***                                                          ***
  7. ;***                Special Function Key Program              ***
  8. ;***                           by                             ***
  9. ;***                    Craig A. Lindley                      ***
  10. ;***                   6 Sutherland Place                     ***
  11. ;***               Manitou Springs, Co. 80829                 ***
  12. ;***                     August 28, 1985                      ***
  13. ;***                 for use with MSDOS 2.x                   ***
  14. ;***                                                          ***
  15. ;****************************************************************
  16. ;
  17. ;
  18. cseg    segment    para    public    'code'
  19.     assume    cs:cseg,ds:cseg
  20. ;
  21.     org    100h
  22. ;
  23. entpt:    jmp    start
  24. ;
  25. ;****************************************************************
  26. ;***              beginning of program data area              ***
  27. ;****************************************************************
  28. ;
  29. ;special function key titles - 6 chars max
  30. ;
  31. titles     db    '  a:  '            ;F1
  32.     db    '  b:  '            ;F2
  33.     db    ' dir  '            ;F3
  34.     db    'dir b:'            ;F4
  35.     db    ' A->B '            ;F5
  36.     db    ' fmt B'            ;F6
  37.     db    'fmt Bs'            ;F7
  38.     db    ' copy '            ;F8
  39.     db    ' cls  '            ;F9
  40.     db    ' help ','$'            ;F10
  41. ;
  42. ;set strings for special function keys
  43. ;
  44. setstr    db    27,'[0;59;"a:";13p'        ;F1
  45.     db    27,'[0;60;"b:";13p'        ;F2
  46.     db    27,'[0;61;"dir";13p'        ;F3
  47.     db    27,'[0;62;"dir b:";13p'        ;F4
  48.     db    27,'[0;63;"diskcopy a: b:";13p'    ;F5
  49.     db    27,'[0;64;"format b:";13p'    ;F6
  50.     db    27,'[0;65;"format b:/s";13p'    ;F7
  51.     db    27,'[0;66;"copy";32p'        ;F8
  52.     db    27,'[0;67;"cls";13p'        ;F9
  53.     db    27,'[0;68;"a:help";13p'        ;F10
  54.     db    '$'
  55. ;
  56. ;reset strings for special function keys
  57. ;
  58. resstr    db    27,'[0;59;0;59p'        ;F1
  59.     db    27,'[0;60;0;60p'        ;F2
  60.     db    27,'[0;61;0;61p'            ;F3
  61.     db    27,'[0;62;0;62p'              ;F4
  62.     db    27,'[0;63;0;63p'                ;F5
  63.     db    27,'[0;64;0;64p'               ;F6
  64.     db    27,'[0;65;0;65p'                ;F7
  65.     db    27,'[0;66;0;66p'            ;F8
  66.     db    27,'[0;67;0;67p'              ;F9
  67.     db    27,'[0;68;0;68p'            ;F10
  68.     db    '$'
  69. ;
  70. ;special display controlling function char strings
  71. ;
  72. p_cur    db    27,'[24;1f$'        ;position cursor str
  73. r_cur    db    27,'[u$'        ;restore cursor pos. str
  74. s_cur    db    27,'[s$'        ;save cursor pos. str
  75. h_vid    db    27,'[0;1m$'        ;high int. video str
  76. r_vid    db    27,'[0;7m$'        ;low  int. reverse video str
  77. n_vid    db    27,'[0;m$'        ;normal video str
  78. eol    db    27,'[K$'        ;erase to end of line str
  79.  
  80. ;****************************************************************
  81. ;***                end of program data area                  ***
  82. ;****************************************************************
  83. ;
  84. ;
  85. ;****************************************************************
  86. ;***                                                          ***
  87. ;***                start of the main program                 ***
  88. ;***                                                          ***
  89. ;****************************************************************
  90. ;
  91. start    proc    near
  92.     call    sav_cur            ;save the current cursor position
  93.     call    display            ;display spec. funct key labels
  94.     call    res_cur
  95.     mov    cx,2000            ;delay loop count
  96. st1:    push    cx            ;save it
  97. ;
  98.     call    poll_keys        ;is keyboard active ?
  99.     jz    st2            ;if not then jump
  100. ;
  101. ;if key hit during delay - reset spec. funct. keys
  102. ;
  103.     mov    dx,offset resstr    ;pt at reset key string
  104.     call    lout            ;send to STDIO device    
  105.     pop    cx              ;fix push on stack
  106.     jmp    short    st3
  107. ;
  108. st2:    pop    cx            ;restore inner loop count
  109.     loop    st1
  110.     mov    dx,offset setstr    ;pt at set key string
  111.     call    lout            ;send to SDTIO device
  112. ;
  113. ;if you get here a key was pressed or time delay is up
  114. ;
  115. st3:    call    norm_vid          ;restore normal video
  116.     call    sav_cur            ;save the cursor position
  117.     call    pos_cur            ;position cursor line 23 char 0        
  118.     call    clreol            ;erase spec. funct. key labels
  119.     call    res_cur            ;restore cursor to where it was
  120.     ret
  121. ;
  122. start    endp
  123. ;
  124. ;****************************************************************
  125. ;***                   Program Subroutines                    ***
  126. ;****************************************************************
  127. ;
  128. clreol    proc    near            ;clear to end of line
  129.     push    dx
  130.     mov    dx,offset eol        ;pt at ansi char str
  131.     call    lout            ;send to SDTIO device
  132.     pop    dx
  133.     ret
  134. clreol    endp
  135. ;
  136. pos_cur    proc    near            ;position cursor line 23 char 0
  137.     push    dx
  138.     mov    dx,offset p_cur        ;pt at ansi char str
  139.     call    lout            ;send to SDTIO device
  140.     pop    dx
  141.     ret
  142. pos_cur    endp
  143. ;
  144. sav_cur    proc    near            ;save cursor position
  145.     push    dx
  146.     mov    dx,offset s_cur        ;pt at ansi char str
  147.     call    lout            ;send to SDTIO device
  148.     pop    dx
  149.     ret
  150. sav_cur    endp
  151. ;
  152. res_cur    proc    near            ;restore cursor position
  153.     push    dx
  154.     mov    dx,offset r_cur        ;pt at ansi char str
  155.     call    lout            ;send to SDTIO device
  156.     pop    dx
  157.     ret
  158. res_cur    endp
  159. ;
  160. norm_vid    proc    near        ;select normal video 
  161.     push    dx
  162.     mov    dx,offset n_vid        ;pt at ansi char str
  163.     call    lout            ;send to SDTIO device
  164.     pop    dx
  165.     ret
  166. norm_vid     endp
  167. ;
  168. hi_vid    proc    near            ;select high int. video 
  169.     push    dx
  170.     mov    dx,offset h_vid        ;pt at ansi char str
  171.     call    lout            ;send to SDTIO device
  172.     pop    dx
  173.     ret
  174. hi_vid     endp
  175. ;
  176. rev_vid    proc    near            ;select reverse video   
  177.     push    dx
  178.     mov    dx,offset r_vid        ;pt at ansi char str
  179.     call    lout            ;send to SDTIO device
  180.     pop    dx
  181.     ret
  182. rev_vid    endp
  183. ;
  184. chrout    proc    near            ;output char to SDTIO device
  185.     push    dx
  186.     mov    dl,al            ;move char to output reg
  187.     mov    ah,6            ;console I/O function code
  188.     int    21h            ;output it
  189.     pop    dx
  190.     ret
  191. chrout    endp
  192. ;
  193. lout    proc    near            ;output line to SDTIO device
  194.     push    ax
  195.     mov    ah,9            ;line out function code
  196.     int    21h            ;output it
  197.     pop    ax
  198.     ret
  199. lout    endp
  200. ;
  201. poll_keys    proc    near        ;poll keyboard for activity
  202.     push    ax
  203.     push    dx
  204.     mov    dl,-1            ;signal for key in
  205.     mov    ah,6            ;console I/O function code
  206.     int    21h            ;do it
  207.     pop    dx
  208.     pop    ax
  209.     ret                ;Z flag set if no key available
  210. poll_keys    endp
  211. ;
  212. display    proc    near            ;display spec funct key labels
  213.     call    pos_cur            ;positon cursor on display
  214.     call    clreol            ;clear line 23
  215.     call    hi_vid          ;select high int. video
  216.     mov    si,offset titles    ;pt at key titles
  217.     mov    cx,10            ;do for 10 key labels
  218.     mov    dl,1            ;loop index
  219. disp1:    push    cx            ;save regs
  220.     push    dx
  221.     mov    al,dl            ;get loop count
  222.     cmp    al,10            ;is it 10 ?
  223.     jne    disp2            ;if not then jump
  224. ;
  225. ;if index = 10 then display "10"
  226. ;
  227.     mov    al,'1'            ;display "1"
  228.     call    chrout
  229.     mov    al,'0'            ;display "0"
  230.     call    chrout
  231.     jmp    short    disp3
  232. ;
  233. disp2:    add    al,'0'            ;make index ascii
  234.     call    chrout            ;display index 1..9
  235. ;
  236. disp3:    call    rev_vid          ;select reverse video
  237.     mov    cx,6            ;do for 6 chars of key title
  238. disp4:    lodsb                ;get char from titles
  239.     call    chrout            ;display it
  240.     loop    disp4
  241. ;
  242.     call    hi_vid          ;normal video
  243.     mov    al,' '            ;output a space
  244.     call    chrout
  245.     pop    dx            ;restore regs
  246.     pop    cx
  247.     inc    dl            ;index=index+1
  248.     loop    disp1
  249.     ret
  250. display    endp
  251. ;
  252. cseg    ends
  253.     end    entpt